package view.dialogs;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JDialog;
import javax.swing.JPanel;

import view.views.dialogContentViews.MessagePanel;
import controller.Controller;

/**
 * @author Alexander Müller
 * 
 */
public abstract class MessageDialog extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final String info;

	public MessageDialog(String title, String info) {

		this.setTitle(title);
		this.info = info;
		setupDialog();
		addContentPanel();
		addButtonPanel();
		this.pack();
		this.setVisible(true);
	}

	private void setupDialog() {
		this.setModal(true);
		this.setMinimumSize(new Dimension(200, 50));
		this.setMaximumSize(new Dimension(450, 150));
		this.setResizable(false);
		this.setLayout(new BorderLayout(0, 0));
		this.setLocationRelativeTo(Controller.getInstance().getGuiBuilder()
				.getFrame());
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

	}

	private void addContentPanel() {

		JPanel contentPanel = new MessagePanel(info);

		this.add(contentPanel, BorderLayout.CENTER);

	}

	private void addButtonPanel() {

		JPanel buttonPanel = addButtons();

		this.add(buttonPanel, BorderLayout.SOUTH);
	}

	protected abstract JPanel addButtons();
}
